#!/usr/bin/python
# this test file creates a file with .working extensions, and writes sum timestamp
# after a few seconds it closes the files, renames it with a .done extensions and 
# exit with a 0 code


import sys
import shutil
import time

def do_test(name, seconds):
    seconds = int(seconds)
    tmpname = '%s.working' % name
    donename = '%s.done' % name
    f = open(tmpname, 'w')
    f.write('%.1f: %s: starting at %s for %d seconds\n' % (time.time(), name, time.asctime(), seconds))
    f.close()
    time.sleep(seconds)
    f = open(tmpname, 'a')
    f.write('%.1f: %s: done at %s\n' % (time.time(), name, time.asctime()))
    f.close()
    shutil.move(tmpname, donename)

if __name__=='__main__':
    if len(sys.argv)==3:
        do_test(*sys.argv[1:])
    else:
        sys.exit(1)
